//
//  NewFound.m
//  YouthHostel
//
//  Created by administrator on 16/10/22.
//  Copyright © 2016年 Lorain mac pro. All rights reserved.
//

#import "NewFound.h"
#import "Define.h"
#import "NewFoundCell.h"
#import "NewFoundCell.h"
#import "AppDelegate.h"
#import "InfoTableViewCell.h"
#import "MessageHotel.h"
@interface NewFound ()<UITableViewDelegate,UITableViewDataSource,UIScrollViewDelegate>

@property (strong,nonatomic)UIImageView *titleView;

@property (strong,nonatomic)UILabel *titleLab1;

@property (strong,nonatomic)UILabel *titleLab2;

@property (strong,nonatomic)UITableView *mytable;

@property (strong,nonatomic)NewFoundCell *mycell;

@property (strong,nonatomic)UIView *contentView;

@property (strong,nonatomic)UIView *contentView2;

@property (strong,nonatomic)UIButton *foundBtn1;

@property (strong,nonatomic)UIButton *foundBtn2;

@property (strong,nonatomic)UILabel *lineLab;

@property (strong,nonatomic)UILabel *lineLab1;

@property (strong,nonatomic)UIScrollView *scroll;

@property (strong,nonatomic)UIView *nav;

@property (strong,nonatomic)UIButton *foundBtn3;

@property (strong,nonatomic)UIButton *foundBtn4;

@property (strong,nonatomic)UILabel *lineLab2;


@end

@implementation NewFound

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    
    self.mytable = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-49) style:UITableViewStylePlain];
    self.mytable.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
    self.mytable.delegate = self;
    self.mytable.dataSource = self;
    self.mytable.contentInset = UIEdgeInsetsMake(120, 0, 0, 0);
    self.mytable.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.mytable.showsHorizontalScrollIndicator = NO;
    self.mytable.showsVerticalScrollIndicator = NO;

    
    self.titleView = [[UIImageView alloc]initWithFrame:CGRectMake(0, -120,WIDTH, 120)];
    self.titleView.image = [UIImage imageNamed:@"06.png"];
    self.titleView.contentMode = UIViewContentModeScaleAspectFill;
    [_titleView setClipsToBounds:YES];
    self.titleView.tag = 101;
    //获取模糊背景
//    [self getImage];
    
    
    self.foundBtn1 = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, (WIDTH-20)/2, 40)];
    [self.foundBtn1 setTitle:@"发现酒店" forState:0];
    [self.foundBtn1 setTitleColor:[UIColor colorWithRed:56/255.0 green:143/255.0 blue:214/255.0 alpha:1] forState:0];
    self.foundBtn1.contentVerticalAlignment =UIControlContentVerticalAlignmentCenter;
    [self.foundBtn1 addTarget:self action:@selector(sliderAction1:) forControlEvents:UIControlEventTouchUpInside];
    self.foundBtn1.titleLabel.font = [UIFont systemFontOfSize:18];
    self.foundBtn1.tag = 1001;
    
    self.foundBtn2 = [[UIButton alloc]initWithFrame:CGRectMake((WIDTH-20)/2, 0, WIDTH/2, 40)];
    [self.foundBtn2 setTitle:@"旅行故事" forState:0];
    [self.foundBtn2 setTitleColor:[UIColor blackColor] forState:0];
    self.foundBtn2.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    self.foundBtn2.titleLabel.font = [UIFont systemFontOfSize:15];
    [self.foundBtn2 addTarget:self action:@selector(sliderAction2:) forControlEvents:UIControlEventTouchUpInside];
    self.foundBtn2.tag = 1002;
    
    self.contentView = [[UIView alloc]initWithFrame:CGRectMake(10, -20, WIDTH-20, 40)];
    self.contentView.backgroundColor = [UIColor whiteColor];
    self.contentView.layer.cornerRadius = 2;
    self.contentView.clipsToBounds = YES;
    
    self.lineLab = [[UILabel alloc]initWithFrame:CGRectMake((WIDTH-20)/2, 10, 1, 20)];
    self.lineLab.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    self.lineLab1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 37, (WIDTH-20)/2, 2)];
    self.lineLab1.backgroundColor = [UIColor colorWithRed:56/255.0 green:143/255.0 blue:214/255.0 alpha:1];
    
    self.nav = [[UIView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, 40)];
    self.nav.backgroundColor = [UIColor whiteColor];
    self.nav.alpha = 0.0;
    
    [self.view addSubview:_mytable];
    [self.view addSubview:_nav];
    [self.mytable addSubview:_titleView];
    [self.mytable addSubview:_contentView];
    [self.contentView addSubview:_foundBtn1];
    [self.contentView addSubview:_foundBtn2];
    [self.contentView addSubview:_lineLab];
    [self.contentView addSubview:_lineLab1];
    
    
    [self setup];
    
    NSLog(@"---------------------%@",NSHomeDirectory());
    
}
//模糊背景
- (void)getImage
{
    UIImage *image = [UIImage imageNamed:@"05.jpg"];
    
    //转换图片
    CIContext *context = [CIContext contextWithOptions:nil];
    
    CIImage *midImage = [CIImage imageWithData:UIImagePNGRepresentation(image)];
    //图片开始处理
    CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"];
    [filter setValue:midImage forKey:kCIInputImageKey];
    //value 改变模糊效果值
    [filter setValue:@2.0f forKey:@"inputRadius"];
    CIImage *result = [filter valueForKey:kCIOutputImageKey];
    CGImageRef outimage = [context createCGImage:result fromRect:[result extent]];
    //转换成UIimage
    UIImage *resultImage = [UIImage imageWithCGImage:outimage];
    CGImageRelease(outimage);
    
    self.titleView.image = resultImage;
}

- (void)setup{

    self.contentView2 = [[UIView alloc]initWithFrame:CGRectMake(10, -20, WIDTH-20, 40)];
    self.contentView2.backgroundColor = [UIColor whiteColor];
    self.contentView2.layer.cornerRadius = 2;
    self.contentView2.clipsToBounds = YES;
    
    self.foundBtn3 = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, (WIDTH-20)/2, 40)];
    [self.foundBtn3 setTitle:@"发现酒店" forState:0];
    [self.foundBtn3 setTitleColor:[UIColor colorWithRed:56/255.0 green:143/255.0 blue:214/255.0 alpha:1] forState:0];
    self.foundBtn3.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    [self.foundBtn3 addTarget:self action:@selector(sliderAction3:) forControlEvents:UIControlEventTouchUpInside];
    self.foundBtn3.titleLabel.font = [UIFont systemFontOfSize:18];
    self.foundBtn3.tag = 1001;
    
    self.foundBtn4 = [[UIButton alloc]initWithFrame:CGRectMake((WIDTH-20)/2, 0, WIDTH/2, 40)];
    [self.foundBtn4 setTitle:@"旅行故事" forState:0];
    [self.foundBtn4 setTitleColor:[UIColor blackColor] forState:0];
    self.foundBtn4.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    self.foundBtn4.titleLabel.font = [UIFont systemFontOfSize:15];
    [self.foundBtn4 addTarget:self action:@selector(sliderAction4:) forControlEvents:UIControlEventTouchUpInside];
    self.foundBtn4.tag = 1002;
    
    self.lineLab2 = [[UILabel alloc]initWithFrame:CGRectMake(0, 37, (WIDTH-20)/2, 2)];
    self.lineLab2.backgroundColor = [UIColor colorWithRed:56/255.0 green:143/255.0 blue:214/255.0 alpha:1];
    
    
    _contentView2.hidden = YES;
    
    [self.contentView2 addSubview:_foundBtn3];
    [self.contentView2 addSubview:_foundBtn4];
    [self.contentView2 addSubview:_lineLab2];
    [self.view addSubview:_contentView2];

}



//状态栏隐藏
- (BOOL)prefersStatusBarHidden
{
    
    return YES;
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return 2;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        return 20;
    }else{
    return 1080;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    _mycell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!_mycell) {
        _mycell = [[NewFoundCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
    }
    if (indexPath.row == 0) {
        _mycell.contentView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    }
    if (indexPath.row == 1) {
        
    self.scroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, 1080)];
    _scroll.contentSize = CGSizeMake(WIDTH*2, HEIGHT-170);
    _scroll.delegate = self;
    _scroll.bounces = NO;
    _scroll.showsHorizontalScrollIndicator = NO;
    _scroll.pagingEnabled = YES;
   [_mycell.contentView addSubview:_scroll];
    
    for (int i = 0; i<6; i++) {
     
    UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10+i*180, WIDTH-20, 160)];
    img.layer.cornerRadius = 3;
        
    UIView *viewbg = [[UIView alloc]initWithFrame:CGRectMake(10, 10+i*180, WIDTH-20, 160)];
    viewbg.backgroundColor = [UIColor blackColor];
    viewbg.alpha = 0.4;
    
    UIButton *btn1 = [[UIButton alloc]initWithFrame:CGRectMake(10, 10+i*180, WIDTH-20, 210)];
    [btn1 addTarget:self action:@selector(goNews:) forControlEvents:UIControlEventTouchUpInside];
        btn1.tag = 1001+i;
        
    UIImageView *titleimg = [[UIImageView alloc]initWithFrame:CGRectMake(WIDTH/2-20, 40+i*180, 40, 30)];
    titleimg.image = [UIImage imageNamed:@"酒店"];
        
    UILabel *line = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH/2-80, 55+i*180, 50, 1)];
    line.backgroundColor = [UIColor whiteColor];
    
    UILabel *line1 = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH/2+30, 55+i*180, 50, 1)];
    line1.backgroundColor = [UIColor whiteColor];
    
    UILabel *titleLab = [[UILabel alloc]initWithFrame:CGRectMake(20, 70+i*180, WIDTH-40, 50)];
    titleLab.textColor = [UIColor whiteColor];
    titleLab.textAlignment = NSTextAlignmentCenter;
    titleLab.font = [UIFont systemFontOfSize:18 weight:UIFontWeightHeavy];

        
        
        if (i == 0) {
            img.image = [UIImage imageNamed:@"酒店1.jpg"];
            titleLab.text = @"盘点那些造型奇特的新型酒店";
        }
        if (i == 1) {
            img.image = [UIImage imageNamed:@"酒店2.jpg"];
            titleLab.text = @"走进日本情趣酒店";
        }
        if (i == 2) {
            img.image = [UIImage imageNamed:@"03.jpg"];
            titleLab.text = @"全球十大酒店排行";
        }
        if (i == 3) {
            img.image = [UIImage imageNamed:@"酒店4.jpg"];
            titleLab.text = @"浪漫主题酒店惟爱你";
        }
        if (i == 4) {
            img.image = [UIImage imageNamed:@"酒店5.jpg"];
            titleLab.text = @"情意浓农亲子酒店";
        }
        if (i == 5) {
            img.image = [UIImage imageNamed:@"酒店6.jpg"];
            titleLab.text = @"酒店客房跨界运营如何玩？";
        }
        
        
        
    UIImageView *img1 = [[UIImageView alloc]initWithFrame:CGRectMake(WIDTH+10, 10+i*180, WIDTH-20, 160)];
    img1.layer.cornerRadius = 3;
        
        UIView *viewbg1 = [[UIView alloc]initWithFrame:CGRectMake(10+WIDTH, 10+i*180, WIDTH-20, 160)];
        viewbg1.backgroundColor = [UIColor blackColor];
        viewbg1.alpha = 0.4;
    
        UIButton *btn2 = [[UIButton alloc]initWithFrame:CGRectMake(10+WIDTH, 10+i*180, WIDTH-20, 210)];
        [btn2 addTarget:self action:@selector(goNews:) forControlEvents:UIControlEventTouchUpInside];
        btn2.tag = 2001+i;
    
        
    UIImageView *titleimg1 = [[UIImageView alloc]initWithFrame:CGRectMake(WIDTH/2-20+WIDTH, 40+i*180, 40, 30)];
    titleimg1.image = [UIImage imageNamed:@"酒店"];
    
        
    UILabel *line2 = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH/2-80+WIDTH, 55+i*180, 50, 1)];
    line2.backgroundColor = [UIColor whiteColor];
    
    UILabel *line3 = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH/2+30+WIDTH, 55+i*180, 50, 1)];
    line3.backgroundColor = [UIColor whiteColor];
    
    UILabel *titleLab1 = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH+20, 70+i*180, WIDTH-40, 50)];
        titleLab1.textColor = [UIColor whiteColor];
        titleLab1.textAlignment = NSTextAlignmentCenter;
        titleLab1.font = [UIFont systemFontOfSize:18 weight:UIFontWeightHeavy];

        if (i == 0) {
            img1.image = [UIImage imageNamed:@"旅行1.jpg"];
            titleLab1.text = @"去想去的地方，见想见得人";
        }
        if (i == 1) {
            img1.image = [UIImage imageNamed:@"旅行2.jpg"];
            titleLab1.text = @"当你轻轻地唱起巴塞罗那";
        }
        if (i == 2) {
            img1.image = [UIImage imageNamed:@"旅行3.jpg"];
            titleLab1.text = @"读在风里的岁月";
        }
        if (i == 3) {
            img1.image = [UIImage imageNamed:@"旅行4.png"];
            titleLab1.text = @"悠游港澳";
        }
        if (i == 4) {
            img1.image = [UIImage imageNamed:@"旅行5.jpg"];
            titleLab1.text = @"驶向幸福的国度";
        }
        if (i == 5) {
            img1.image = [UIImage imageNamed:@"旅行美食.jpg"];
            titleLab1.text = @"多伦多美食攻略";
        }
 
        
        
    [_scroll addSubview:img];
        [_scroll addSubview:viewbg];
    [_scroll addSubview:line];
    [_scroll addSubview:line1];
    [_scroll addSubview:titleLab];
    [_scroll addSubview:titleimg];
        [_scroll addSubview:btn1];
        
    [_scroll addSubview:img1];
        [_scroll addSubview:viewbg1];
    [_scroll addSubview:line2];
    [_scroll addSubview:line3];
    [_scroll addSubview:titleLab1];
    [_scroll addSubview:titleimg1];
        [_scroll addSubview:btn2];

       

    }
        
    }
    return _mycell;
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
    [appDelegate.selfTAB showTabView];
    
    [self.tabBarController.tabBar setHidden:NO];
}

//隐藏TabBar
- (void)hiddenTabBar{
    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
    [appDelegate.selfTAB hideTabView];
    
    [self.tabBarController.tabBar setHidden:YES];
    
}

- (void)goNews:(UIButton *)sender
{
    MessageHotel *message = [[MessageHotel alloc]init];
    message.delegate  = self;
    
    if (sender.tag == 1001) {
       
        message.urlStr = URL1;
        
    }
    if (sender.tag == 1002) {
        
        message.urlStr = URL2;
      
    }
    if (sender.tag == 1003) {
        
        message.urlStr = URL3;
       
    }
    if (sender.tag == 1004) {
        
        message.urlStr = URL4;
       
    }
    if (sender.tag == 1005) {
        
        message.urlStr = URL5;
       
    }
    if (sender.tag == 1006) {
        
        message.urlStr = URL6;
        
    }
    
    if (sender.tag == 2001) {
        
        message.urlStr = URL7;
        
    }
    if (sender.tag == 2002) {
        
        message.urlStr = URL8;
        
    }
    if (sender.tag == 2003) {
        
        message.urlStr = URL9;
      
    }
    if (sender.tag == 2004) {
        
        message.urlStr = URL10;
       
    }
    if (sender.tag == 2005) {
        
        message.urlStr = URL11;
      
    }
    if (sender.tag == 2006) {
        
        message.urlStr = URL12;
        
    }
    [self hiddenTabBar];
    [self.navigationController pushViewController:message animated:YES];
}

-(UIButton *)buttonWithTag:(NSInteger)tag{
    if (tag==1001) {
        return _foundBtn1;
    }else if (tag==1002){
        return _foundBtn2;
    }if (tag==1001) {
        return _foundBtn1;
    }else if (tag==1002){
        return _foundBtn2;
    }else{
        return nil;
    }
}

-(void)sliderAction1:(UIButton *)sender{
    
    [UIView animateWithDuration:0.3 animations:^{
        
        self.lineLab1.frame = CGRectMake(sender.frame.origin.x, self.lineLab1.frame.origin.y, self.lineLab1.frame.size.width, self.lineLab1.frame.size.height);
        
        self.lineLab2.frame = CGRectMake(_foundBtn3.frame.origin.x, self.lineLab2.frame.origin.y, self.lineLab1.frame.size.width, self.lineLab2.frame.size.height);
        
        self.scroll.contentOffset = CGPointMake(WIDTH * (sender.tag - 1001), 0);
        
    } completion:^(BOOL finished) {
        self.foundBtn1.titleLabel.font = [UIFont systemFontOfSize:18];
        [self.foundBtn1 setTitleColor:[UIColor colorWithRed:56/255.0 green:143/255.0 blue:214/255.0 alpha:1] forState:UIControlStateNormal];
        
        self.foundBtn2.titleLabel.font = [UIFont systemFontOfSize:15];
        [self.foundBtn2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        self.foundBtn3.titleLabel.font = [UIFont systemFontOfSize:18];
        [self.foundBtn3 setTitleColor:[UIColor colorWithRed:56/255.0 green:143/255.0 blue:214/255.0 alpha:1] forState:UIControlStateNormal];
        
        self.foundBtn4.titleLabel.font = [UIFont systemFontOfSize:15];
        [self.foundBtn4 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
    }];
    
}

-(void)sliderAction2:(UIButton *)sender{
    
    [UIView animateWithDuration:0.3 animations:^{
        
        self.lineLab1.frame = CGRectMake(sender.frame.origin.x, self.lineLab1.frame.origin.y, self.lineLab1.frame.size.width, self.lineLab1.frame.size.height);
        
        self.lineLab2.frame = CGRectMake(_foundBtn4.frame.origin.x, self.lineLab2.frame.origin.y, self.lineLab1.frame.size.width, self.lineLab2.frame.size.height);
        self.scroll.contentOffset = CGPointMake(WIDTH * (sender.tag - 1001), 0);
        
    } completion:^(BOOL finished) {
        
        self.foundBtn2.titleLabel.font = [UIFont systemFontOfSize:18];
        [self.foundBtn2 setTitleColor:[UIColor colorWithRed:56/255.0 green:143/255.0 blue:214/255.0 alpha:1] forState:UIControlStateNormal];
        
        self.foundBtn1.titleLabel.font = [UIFont systemFontOfSize:15];
        [self.foundBtn1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        self.foundBtn4.titleLabel.font = [UIFont systemFontOfSize:18];
        [self.foundBtn4 setTitleColor:[UIColor colorWithRed:56/255.0 green:143/255.0 blue:214/255.0 alpha:1] forState:UIControlStateNormal];
        
        self.foundBtn3.titleLabel.font = [UIFont systemFontOfSize:15];
        [self.foundBtn3 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        
    }];
    
}

-(void)sliderAction3:(UIButton *)sender{
    
    [UIView animateWithDuration:0.3 animations:^{
        
        self.lineLab1.frame = CGRectMake(sender.frame.origin.x, self.lineLab1.frame.origin.y, self.lineLab1.frame.size.width, self.lineLab1.frame.size.height);
        
        self.lineLab2.frame = CGRectMake(_foundBtn1.frame.origin.x, self.lineLab2.frame.origin.y, self.lineLab1.frame.size.width, self.lineLab2.frame.size.height);
        self.scroll.contentOffset = CGPointMake(WIDTH * (sender.tag - 1001), 0);
        
    } completion:^(BOOL finished) {
        
        self.foundBtn1.titleLabel.font = [UIFont systemFontOfSize:18];
        [self.foundBtn1 setTitleColor:[UIColor colorWithRed:56/255.0 green:143/255.0 blue:214/255.0 alpha:1] forState:UIControlStateNormal];
        
        self.foundBtn2.titleLabel.font = [UIFont systemFontOfSize:15];
        [self.foundBtn2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        self.foundBtn3.titleLabel.font = [UIFont systemFontOfSize:18];
        [self.foundBtn3 setTitleColor:[UIColor colorWithRed:56/255.0 green:143/255.0 blue:214/255.0 alpha:1] forState:UIControlStateNormal];
        
        self.foundBtn4.titleLabel.font = [UIFont systemFontOfSize:15];
        [self.foundBtn4 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    }];
    
}

-(void)sliderAction4:(UIButton *)sender{
    
    
    [UIView animateWithDuration:0.3 animations:^{
        
        self.lineLab1.frame = CGRectMake(sender.frame.origin.x, self.lineLab1.frame.origin.y, self.lineLab1.frame.size.width, self.lineLab1.frame.size.height);
        
        self.lineLab2.frame = CGRectMake(_foundBtn3.frame.origin.x, self.lineLab2.frame.origin.y, self.lineLab1.frame.size.width, self.lineLab2.frame.size.height);
        
        self.scroll.contentOffset = CGPointMake(WIDTH * (sender.tag - 1001), 0);
        
    } completion:^(BOOL finished) {
        self.foundBtn2.titleLabel.font = [UIFont systemFontOfSize:18];
        [self.foundBtn2 setTitleColor:[UIColor colorWithRed:56/255.0 green:143/255.0 blue:214/255.0 alpha:1] forState:UIControlStateNormal];
        
        self.foundBtn1.titleLabel.font = [UIFont systemFontOfSize:15];
        [self.foundBtn1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        self.foundBtn4.titleLabel.font = [UIFont systemFontOfSize:18];
        [self.foundBtn4 setTitleColor:[UIColor colorWithRed:56/255.0 green:143/255.0 blue:214/255.0 alpha:1] forState:UIControlStateNormal];
        
        self.foundBtn3.titleLabel.font = [UIFont systemFontOfSize:15];
        [self.foundBtn3 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    }];
    
}

- (void)sliderAnimationWithTag:(NSInteger)tag{
    self.foundBtn1.selected = NO;
    self.foundBtn2.selected = NO;
    self.foundBtn3.selected = NO;
    self.foundBtn4.selected = NO;
    UIButton *sender = [self buttonWithTag:tag];
    sender.selected = YES;
    //动画
    [UIView animateWithDuration:0.3 animations:^{
        self.lineLab1.frame = CGRectMake(sender.frame.origin.x, self.lineLab1.frame.origin.y, self.lineLab1.frame.size.width, self.lineLab1.frame.size.height);
        
        self.lineLab2.frame = CGRectMake(sender.frame.origin.x, self.lineLab2.frame.origin.y, self.lineLab1.frame.size.width, self.lineLab2.frame.size.height);
        
    } completion:^(BOOL finished) {
        
        if (sender.tag == 1001) {
            self.foundBtn1.titleLabel.font = [UIFont systemFontOfSize:18];
            [self.foundBtn1 setTitleColor:[UIColor colorWithRed:56/255.0 green:143/255.0 blue:214/255.0 alpha:1] forState:UIControlStateNormal];
            
            self.foundBtn2.titleLabel.font = [UIFont systemFontOfSize:15];
            [self.foundBtn2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            
            self.foundBtn4.titleLabel.font = [UIFont systemFontOfSize:15];
            [self.foundBtn4 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            
            self.foundBtn3.titleLabel.font = [UIFont systemFontOfSize:18];
            [self.foundBtn3 setTitleColor:[UIColor colorWithRed:56/255.0 green:143/255.0 blue:214/255.0 alpha:1] forState:UIControlStateNormal];
          }
        if (sender.tag == 1002) {
            
            self.foundBtn1.titleLabel.font = [UIFont systemFontOfSize:15];
            [self.foundBtn1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            
            self.foundBtn2.titleLabel.font = [UIFont systemFontOfSize:18];
            [self.foundBtn2 setTitleColor:[UIColor colorWithRed:56/255.0 green:143/255.0 blue:214/255.0 alpha:1] forState:UIControlStateNormal];
            
            
            self.foundBtn3.titleLabel.font = [UIFont systemFontOfSize:15];
            [self.foundBtn3 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            
            self.foundBtn4.titleLabel.font = [UIFont systemFontOfSize:18];
            [self.foundBtn4 setTitleColor:[UIColor colorWithRed:56/255.0 green:143/255.0 blue:214/255.0 alpha:1] forState:UIControlStateNormal];
        }
        
    }];
    
}

//cell点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];    
}

//头像拉伸效果
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
   
    
    
    CGFloat offsetY = scrollView.contentOffset.y;
    CGPoint point = scrollView.contentOffset;
    
    if (point.y < -120) {
        CGRect rect = [self.mytable viewWithTag:101].frame;

        rect.origin.x = point.y+120;
        rect.origin.y = point.y;
        rect.size.width = (-point.y-120)*2+WIDTH;
        rect.size.height = -point.y;
        [self.mytable viewWithTag:101].frame = rect;

    }
    
    if (scrollView == _scroll) {
        double index_ = self.scroll.contentOffset.x / WIDTH;
        [self sliderAnimationWithTag:(int)(index_+0.5)+1001];
    }
    
    
    
    
    
    if (scrollView == _mytable) {

        NSLog(@"-------XxxX->>%f",offsetY);
        if (offsetY >= -60) {
            
            CGFloat x = offsetY;
            
            _nav.alpha = (offsetY+60)/40;
            
            NSLog(@"%f",offsetY );
            
            _contentView2.hidden = NO;

            while (x >= - 21) {
                
                x = - 21;
                
                break;
                
            }
            
            _contentView2.frame = CGRectMake(10, -x - 21, WIDTH-20, 40);

        }else{
            
            _nav.alpha = 0.0;
            
            _contentView2.hidden = YES;
        
        }

    }
    
}


@end

